package com.ziyueyuwen.xiniao.controller.question.point;

import com.suyeer.basic.util.HttpResUtil;
import com.ziyueyuwen.xiniao.base.HttpResContent;
import com.ziyueyuwen.xiniao.bean.question.PointSelectBean;
import com.ziyueyuwen.xiniao.service.PointService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import java.util.List;

import static com.ziyueyuwen.xiniao.base.BaseUtil.saveErrorMsgAndData;
import static com.ziyueyuwen.xiniao.base.BaseUtil.saveSuccessMsgAndData;

/**
 * @author wancheng  on 2019/1/9.
 */
@Controller
@RequestMapping("/question/point")
public class PointController {

    private final static Logger logger = LoggerFactory.getLogger(PointController.class);

    @Autowired
    PointService pointService;

    @RequestMapping(value = "get_points.do",method = RequestMethod.POST)
    public void updateStudent(HttpServletRequest request,
                              HttpServletResponse response) {
        HttpResContent<List<PointSelectBean>> hrc = new HttpResContent<>(request, response);
        hrc.setFuncDes("获取知识点");
        try {
            List<PointSelectBean> points = pointService.getPointSelectBean();
            saveSuccessMsgAndData(hrc, points);
        } catch (Exception e) {
            e.printStackTrace();
            saveErrorMsgAndData(hrc, e);
        } finally {
            HttpResUtil.writeResult(hrc, true);
        }
    }
}
